import { computed } from "vue";

export const useComputed = (func) => {
  const computedMap = new Map();
  
  return function (...args) {
    const key = JSON.stringify(args);
    
    if (computedMap.has(key)) {
      return computedMap.get(key);
    } else {
      // 创建一个计算属性，将函数应用于参数
      const result = computed(() => func(...args));
      computedMap.set(key, result);
      return result;
    }
  };
};
